package com.cloudfun.campusshare.common.constant;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author : linyangping
 * @Date : Created in 5:19 PM 2019/11/19
 */
public enum AuthStatus {
    UNAUTH(0, "未认证"),
    AUTHING(1, "认证中"),
    AUTH_SUCCESS(2, "认证成功"),
    AUTH_FAILURE(3, "认证失败");

    private int code;
    private String status;

    AuthStatus(int code, String status) {
        this.code = code;
        this.status = status;
    }

    public int getCode() {
        return code;
    }

    public String getStatus() {
        return status;
    }

    private static Map<Integer, AuthStatus> codeInstanceMap = new HashMap<>();

    static {
        for (AuthStatus instance : AuthStatus.values()) {
            codeInstanceMap.put(instance.getCode(), instance);
        }
    }

    public static AuthStatus fromCode(Integer code) {
        return codeInstanceMap.get(code);
    }
}
